package array;

public class ChaoDai
{
	private String name;
	private short guoZuo;
	private String capital;
	private int stYear;
	public King[] huang = new King[3];
	private int a = 0;
	private int  addNum = 2;

	public ChaoDai()
	{

	}

	public ChaoDai(String name, int stYear)
	{
		this.name = name;
		this.stYear = stYear;
	}

	public ChaoDai(String name, int stYear, short guoZuo, String capital)
	{
		this(name, stYear);
		this.guoZuo = guoZuo;
		this.capital = capital;
	}

	public String toString()
	{
		String result = "朝代:name:" + this.name + ";guoZuo:" + this.guoZuo + ";";
		result = result + "首都:" + this.capital + ";开国时间:" + this.stYear;
		return result;
	}

	public String getName()
	{
		return this.name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public short getGuoZuo()
	{
		return this.guoZuo;
	}

	public void setGuoZuo(short guoZuo)
	{
		this.guoZuo = guoZuo;
	}

	public String getCapital()
	{
		return this.capital;
	}

	public void setCapital(String capital)
	{
		this.capital = capital;
	}

	public int getStYear()
	{
		return this.stYear;
	}

	public void setStYear(int stYear)
	{
		this.stYear = stYear;
	}

	public boolean add(King ob)
	{
		this.huang[this.a] = ob;
		this.a++;
		if(this.a == this.huang.length) 
		{
			King newhuang [] = new King[this.a  + this.addNum];
			for(int i = 0 ; i < this.huang.length; i++)
			{
				newhuang[i] = huang[i];
			}
			this.huang = newhuang;
		}
		return true;
	}
	public void select()
	{
		for(int i = 0; i < this.a;i++) 
		{
			System.out.println(i+"循环输出"+huang[i]);
		}
	}
}